<?php  
class OrderController extends Controller{
	private $db;
	/**
	 * 构造函数
	 * @return [type] [description]
	 */
	public function __init(){
		//验证登录
		if (!$_SESSION['user']['uid']) {
			go('Login/login');
		}
		$this->db=K('Order');
	}

	/**
	 * 我的订单 订单列表
	 * @return [type] [description]
	 */
	public function index(){

		$this->display();
	}
	/**
	 * 添加订单
	 */
	public function add(){
		if (IS_POST) {
			if ($this->db->addOrder()) {
				$this->success('删除成功');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display();
		}
	}
	/**
	 * 编辑订单
	 * 未付款派送的订单才可以编辑
	 * @return [type] [description]
	 */
	public function edit(){
		if (IS_POST) {
			if ($this->db->editOrder()) {
				$this->success('删除成功');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display();
		}
	}
	/**
	 * 删除订单
	 * @return [type] [description]
	 */
	public function del(){
		if ($this->db->delOrder()) {
			$this->success('删除成功');
		}else{
			$this->error($this->db->error);
		}
	}

}
?>